package com.aaa.sys.service.impl;

import com.aaa.sys.entity.Notice;
import com.aaa.sys.mapper.NoticeMapper;
import com.aaa.sys.service.NoticeService;
import com.aaa.sys.vo.NoticeResult;
import com.aaa.sys.vo.NoticeVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 通知表 服务实现类
 * </p>
 *
 * @author ykq
 * @since 2020-12-08
 */
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements NoticeService {

    @Autowired
    private NoticeMapper noticeMapper;
    @Override
    public IPage<NoticeResult> findByCondication(Integer page, Integer limit, NoticeVo noticeVo) {
        QueryWrapper<Notice> wrapper=new QueryWrapper<>();

        if(StringUtils.isNotEmpty(noticeVo.getTitle())){
            wrapper.like("title",noticeVo.getTitle());
        }
        Page<NoticeResult> page1=new Page<NoticeResult>(page,limit);
        IPage<NoticeResult> noticeResultIPage = this.noticeMapper.selectWithUserPage(page1, wrapper);
        return noticeResultIPage;
    }
}
